#ifndef __SOIL_BLOCK_H__
#define __SOIL_BLOCK_H__

#include "Block.hpp"

namespace PocketSurvival
{
    // 耕地
    class SoilBlock : public Block
    {
    public:
        static constexpr int32_t Index()
        {
            return 168;
        }
        virtual int32_t getIndex() override; 
        virtual const std::string &getBlockName() override;

        virtual void getCreativeValues(std::vector<int32_t> &blockVec) override;
        virtual const std::vector<BoundingBox> &getCustomCollisionBoxes(int32_t value) override;

        static inline bool GetHydration(int32_t data);
        static inline int32_t GetNitrogen(int32_t data);
        static inline int32_t SetHydration(int32_t data, bool hydration);
        static inline int32_t SetNitrogen(int32_t data, int32_t nitrogen);
    };

	inline bool SoilBlock::GetHydration(int32_t data)
	{
		return (data & 1) != 0;
	}

	inline int32_t SoilBlock::GetNitrogen(int32_t data)
	{
		return (data >> 1) & 3;
	}

	inline int32_t SoilBlock::SetHydration(int32_t data, bool hydration)
	{
		if (!hydration)
		{
			return data & -2;
		}
		return data | 1;
	}

	inline int32_t SoilBlock::SetNitrogen(int32_t data, int32_t nitrogen)
	{
		nitrogen = MathUtils::Clamp<int32_t>(nitrogen, 0, 3);
		return (data & -7) | ((nitrogen & 3) << 1);
	}


} // namespace PocketSurvival


#endif
